package ji.sky.fragmentdemo;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private TextView tv_ch1;
    private TextView tv_ch2;
    private TextView tv_content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tv_ch1 = findViewById(R.id.tv_ch1);
        tv_ch2 = findViewById(R.id.tv_ch2);
        tv_content = findViewById(R.id.tv_content);
        tv_ch1.setOnClickListener(this);
        tv_ch2.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_ch1:
                tv_content.setText(R.string.ch1_content);
                break;
            case R.id.tv_ch2:
                tv_content.setText(R.string.ch2_content);
                break;
            default:
                break;
        }
    }
}